{% extends 'base.html' %}
{% block body %}
  <div class="fly-panel fly-column">
    <div class="layui-container">
      <ul class="layui-clear">
        <li class="layui-hide-xs {{ 'layui-this' if is_index }}"><a href="/">综合</a></li>
        {% for item in get_list('catalogs', sort_by=('sort_key', 1)) %}
          <li class="layui-hide-xs {{ 'layui-this' if catalog_id == item._id }}"><a
                  href="/catalog/{{ item._id }}">{{ item.name }}</a></li>
        {% endfor %}

        <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>
        {% if current_user.is_authenticated %}
          <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{{ url_for('user.user_posts') }}">我发表的贴</a></li>
          <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a
                  href="{{ url_for('user.user_posts') + '#collection' }}">我收藏的贴</a></li>
        {% endif %}

      </ul>

      <div class="fly-column-right layui-hide-xs">
        <span class="fly-search"><i class="layui-icon"></i></span>
        <a href="{{ url_for('index.add') }}" class="layui-btn">发表新帖</a>
      </div>
      <div class="layui-hide-sm layui-show-xs-block"
           style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
        <a href="{{ url_for('index.add') }}" class="layui-btn">发表新帖</a>
      </div>
    </div>
  </div>

  <div class="layui-container">
    <div class="layui-row layui-col-space15">

        {% block content %}
        {% endblock %}
      <div class="layui-col-md4">

        {% if is_index %}
          <div class="fly-panel">
            <h3 class="fly-panel-title">温馨通道</h3>
            <ul class="fly-panel-main fly-list-static">
              {% for item in get_list('passageways', sort_by=('sort', -1)) %}
                <li>
                <a href="{{ item.url }}" target="_blank">{{ item.name }}</a>
              </li>
              {% endfor %}
            </ul>
          </div>

            {% if current_user.is_authenticated %}
                <div class="fly-panel fly-signin">
                    <div class="fly-panel-title">
                        签到
                        <i class="fly-mid"></i>
                        <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
                    </div>
                    <div class="fly-panel-main fly-signin-main">

                    </div>
                </div>
            {% endif %}


        <div class="fly-panel">
          <div class="fly-panel-title">
            友情赞助
          </div>
          <div class="fly-panel-main">
            {% for item in get_list('ads', sort_by=('sort', -1)) %}
              <a href="{{ item.url }}" target="_blank" class="fly-zanzhu" style="background-color: {{ item.color|safe or '#5FB878' }};">{{ item.name }}</a>
            {% endfor %}

          </div>
        </div>

          <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
            <h3 class="fly-panel-title">回贴榜</h3>
            <dl>
              <!--<i class="layui-icon fly-loading">&#xe63d;</i>-->
              {% for item in get_list('users', sort_by=('reply_count',-1), size=12) %}
                <dd>
                  <a href="/user/{{ item._id }}">
                    <img src="{{ item.avatar }}"><cite>{{ item.username }}</cite><i>{{ item.get('reply_count', 0) }}次回答</i>
                  </a>
                </dd>
              {% else %}
                <div class="fly-none">没有相关数据</div>
              {% endfor %}
            </dl>
          </div>
        {% endif %}


        <dl class="fly-panel fly-list-one">
          <dt class="fly-panel-title">本周热议</dt>
          {% for item in get_list('posts', sort_by=('comment_count',-1), size=10, filter1={'create_at':{'$gte': date_cal(now(), 7, False)}}) %}
            <dd>
              <a href="/post/{{ item._id }}">{{ item.title }}</a>
              <span><i class="iconfont icon-pinglun1"></i> {{ item.get('comment_count', 0) }}</span>
            </dd>
          {% else %}
            <div class="fly-none">没有相关数据</div>
          {% endfor %}
        </dl>

        <div class="fly-panel fly-link">
          <h3 class="fly-panel-title">友情链接</h3>
          <dl class="fly-panel-main">
            {% for item in get_list('friend_links', sort_by=('sort', -1)) %}
              <dd><a href="{{ item.url }}" target="_blank">{{ item.name }}</a></dd>
            {% endfor %}
            <dd><a href="mailto:{{ get_option('email').val }}?subject=%E7%94%B3%E8%AF%B7Fly%E7%A4%BE%E5%8C%BA%E5%8F%8B%E9%93%BE"
                   class="fly-link">申请友链</a>
            <dd>
          </dl>
        </div>

      </div>
    </div>
  </div>
{% endblock %}